﻿using Esri.ArcGISRuntime.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using WRJClient.UI.Map;

namespace WRJClient.ViewModel
{
    public abstract class BaseViewModel<T> : INotifyPropertyChanged where T : new()
    {

        protected T _staticData;
        public T StaticData
        {
            get { return _staticData; }
        }
        public event PropertyChangedEventHandler PropertyChanged;

        protected BaseViewModel(T model = default(T))
        {
            if (model == null)
            {
                model = new T();
            }
            _staticData = model;
        }
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        public virtual void SetData(T model)
        {
            _staticData = model;
            OnPropertyChanged("StaticData");
        }
    }
}
